<template>
  <div>
    <el-form label-position="left" label-width="100px" class="demo-ruleForm login-container">
      <h3 class="title">店铺入驻激活</h3>
      <el-form-item style="width:100%;">
        <el-button size="small" type="primary" @click="getActive">激 活</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>

export default {
  // 店铺激活
  name: "ShopActive",
  methods: {
    getActive() {
      // 获取地址栏地址 - http://localhost:8081/#/login/?id
      var href = window.location.href;
      // 获取id - http://localhost:8081/#/login/?id
      var id = href.substring(href.lastIndexOf("?") + 1);

      this.$confirm('确认激活吗?', '提示', { // 点击了确认框
      }).then(() => {
        // 发送异步请求,激活店铺
        this.$http.get("/shop/active/" + id).then(res => {
          if (res.data.success) {
            this.$message.success("激活成功! 请登录!!");
            // 激活成功后跳转到登录页面 - 使用路由的方式跳转页面
            this.$router.push({path: '/login'});
          } else {
            this.$message.error("激活失败，请稍后重试!!!【500】");
          }
        }).catch(res => {
          this.$message.error("激活失败，请稍后重试!!!【400,404】");
        })
      }).catch(() => {

      });
    }
  },
  mounted() {
    this.getActive();
  }
}

</script>

<style lang="scss" scoped>

</style>